//设置月份列表
function setupMonthList(chapterArr, year) {
	$('#month_list').html('');
	var chapterHtmlStr = '';
	for (var i = 0; i < chapterArr.length; i++) {
		var chapterData = chapterArr[i];
		chapterHtmlStr += setMonthUi(i + 1, chapterData, year);
		loadDayData(i + 1, chapterData.month, year);
	}
	$('#monthItem' + year).append(chapterHtmlStr);
	$('#monthItem' + year).children(".guijiItemBd_month").children(".guijiItemHd_month").click(function() {
		if ($(this).next(".day_list").is(":hidden")) {
			$(this).next(".day_list").stop(true, true).slideDown();
			$(this).find(".month").css("background", "url(../../icon/jiaobiao_down.png) no-repeat 93% center");
		} else {
			$(this).next(".day_list").stop(true, true).slideUp();
			$(this).find(".month").css("background", " url(../../icon/jiaobiao_up.png) no-repeat 93% center");
		}
		$(this).find(".month").css("background-size", "10px");
	})
}

//设置日期列表
function setupDayList(month, chapterArr, year) {
	$('#month_list').html('');
	var subChapterHtmlStr = '';
	for (var i = 0; i < chapterArr.length; i++) {
		var chapterData = chapterArr[i];
		subChapterHtmlStr += setDayUI(i + 1, chapterData, month);
		loadHourData(i + 1, month, year, chapterData.day);

	}

	$('#dayItem' + month + year).append(subChapterHtmlStr);
	$('#dayItem' + month + year).children(".guijiItemBd_day").children(".guijiItemHd_day").click(function() {
		if ($(this).next(".hour_list").is(":hidden")) {
			$(this).next(".hour_list").stop(true, true).slideDown();
			$(this).find(".day").css("background", "url(../../icon/jiaobiao_down.png) no-repeat 32% center");
		} else {
			$(this).next(".hour_list").stop(true, true).slideUp();
			$(this).find(".day").css("background", " url(../../icon/jiaobiao_up.png) no-repeat 32% center");
		}
		$(this).find(".day").css("background-size", "10px");
	})
}

//设置小时列表
function setupHourList(day, chapterArr, month) {
	$('#month_list').html('');
	var subChapterHtmlStr = '';
	for (var i = 0; i < chapterArr.length; i++) {
		var chapterData = chapterArr[i];
		subChapterHtmlStr += setHourUI(i + 1, day, chapterData);
	}
	$('#hourItem' + day + month).append(subChapterHtmlStr);

}

//判断积分正负
function judgePointsPositiveAndnegative(num) {
	if (num > 0) {
		return "+" + num;
	} else if (num < 0) {
		return num;
	} else {
		return num;
	}

}

//设置顶部chart图表数据数组
function setupTopChartArr(list, sumPoint) {
	var data = list.data;
	var topArr = new Array();
	for (var i = 0; i < data.length; i++) {
		topArr.push({
			name : data[i].name,
			value : data[i].points,
		});

	}
	setupTopChart(topArr, sumPoint);
}

//设置顶部图表
function setupTopChart(topArr, sumPoint) {
	var myChart = echarts.init(document.getElementById('top_chart'));
	var titleStr = sumPoint + "积分"
	myChart.setOption({
		title : {
			text : titleStr,
			x : 'center',
			y : 'center',
			textStyle : {
				fontWeight : 'normal',
				color : '#0580f2',
				fontSize : '12'
			}
		},
		tooltip : {
			trigger : 'item',
			formatter : "{d}% <n/>{a} <br/>{b} : {c}积分"
		},
		calculable : false,
		series : [{
			name : '',
			type : 'pie',
			radius : [40, 70],
			center : ['50%', '50%'],
			roseType : 'radius',
			//			label : {
			//				normal : {
			//					textStyle : {
			//						fontSize : 14
			//					},
			//					formatter : function(param) {
			//						return param.name + '\n' + Math.round(param.percent) + '%'+ '\r' +param.value+'积分';
			//					}
			//				}
			//			},
			data : topArr
		}]
	});
}

//组合series所需数组
function AddSeriesArr(data) {
	var seriesArr = new Array();
	var colorArr = ["#aa68da", "#06bcff ", "#66cccc", "#a3d146", "#f16bae", "#e15517", "#ff9900", "#fcdb00"];
	for (var i = 0; i < data.length; i++) {
		seriesArr.push({
			value : data[i].points,
			name : data[i].name + '积分',
			itemStyle : {
				color : colorArr[i]
			}
		});
	}
	return seriesArr;
}

//组合series所需数组
function AddlegendArr(data) {
	var colorArr = ["#aa68da", "#06bcff ", "#66cccc", "#a3d146", "#f16bae", "#e15517", "#ff9900", "#fcdb00"];
	var legendArr = new Array();
	for (var i = 0; i < data.length; i++) {
		legendArr.push({
			name : data[i].name + '积分',
		});
	}
	return legendArr;
}





//打开积分规则页
function openRule() {
	api.openWin({useWKWebView:true,
		name : 'IntegralRule_Win',
		url : '../AccumulatePoints/IntegralRule_Win.html'
	});
}